package com.fanshuai.soring.boot;

import com.fanshuai.soring.boot.annotations.EnableWebFluxMetrics;
import com.fanshuai.soring.boot.annotations.EnableWebFluxRequestLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.reactive.HandlerAdapter;
import org.springframework.web.reactive.HandlerMapping;
import org.springframework.web.reactive.function.server.support.HandlerFunctionAdapter;
import org.springframework.web.reactive.result.SimpleHandlerAdapter;
import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebHandler;
import org.springframework.web.server.adapter.HttpWebHandlerAdapter;
import org.springframework.web.server.handler.ExceptionHandlingWebHandler;
import org.springframework.web.server.handler.FilteringWebHandler;

import java.util.Map;

@Slf4j
@SpringBootApplication
@EnableWebFluxMetrics
@EnableWebFluxRequestLog
public class ApplicationStarter {

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(ApplicationStarter.class, args);

        Map<String, HandlerMapping> handlerMappingMap = context.getBeansOfType(HandlerMapping.class);
        log.info("handler mappings={}", handlerMappingMap);

        Map<String, HandlerAdapter> handlerAdapterMap = context.getBeansOfType(HandlerAdapter.class);
        log.info("handler adapters={}", handlerAdapterMap);

        Map<String, WebHandler> handlerMap = context.getBeansOfType(WebHandler.class);
        log.info("handlers={}", handlerMap);

        Map<String, WebFilter> filterMap = context.getBeansOfType(WebFilter.class);
        log.info("filters={}", filterMap);

        SimpleHandlerAdapter adapter;
        HandlerFunctionAdapter handlerFunctionAdapter;
        RequestMappingHandlerAdapter requestMappingHandlerAdapter;
        HttpWebHandlerAdapter httpWebHandlerAdapter;
        ExceptionHandlingWebHandler webHandler;
        FilteringWebHandler filteringWebHandler;
        DispatcherHandler dispatcherHandler;
    }
}
